﻿using System.Collections.Generic;
using System.Xml.Serialization;

namespace AutoUpdater.Models
{
    /// <summary>
    /// 
    /// </summary>
    [XmlRoot(ElementName = "manifest")]
    public class UptBaseModel
    {
        public UptBaseModel()
        {
            version = "1.0.0.0";
            files = new List<FileInfoModel>();
        }

        /// <summary>
        /// 主版本号
        /// </summary>
        [XmlElement("version")]
        public string version { get; set; }
        /// <summary>
        /// 更新说明
        /// </summary>
        [XmlElement("description")]
        public string description { get; set; }

        /// <summary>
        /// 服务地址
        /// </summary>
        [XmlElement("server")]
        public string server { get; set; }

        /// <summary>
        /// 文件数量
        /// </summary>
        [XmlElement("count")]
        public int count { get; set; }

        [XmlIgnore]
        public int updatingCount { get; set; }

        [XmlIgnore]
        public int updateCount { get; set; }

        [XmlIgnore]
        public long totalFileSize { get; set; }
        [XmlArray("files")]
        [XmlArrayItem("file")]
        public List<FileInfoModel> files { get; set; }
    }

    public class FileInfoModel
    {
        /// <summary>
        /// 文件hash指纹
        /// </summary>
        [XmlElement("hash1")]
        public string hash1 { get; set; }
        /// <summary>
        /// 文件名
        /// </summary>
        [XmlElement("fileName")]
        public string fileName { get; set; }
        /// <summary>
        /// 文件路径
        /// </summary>
        [XmlElement("filePath")]
        public string filePath { get; set; }
        /// <summary>
        /// 地址指向
        /// </summary>
        [XmlElement("fileDrect")]
        public string fileDrect { get; set; }
        /// <summary>
        /// 文件地址
        /// </summary>
        [XmlElement("urlDrect")]
        public string urlDrect { get; set; }
        /// <summary>
        /// 文件版本号
        /// </summary>
        [XmlElement("fileVer")]
        public string fileVer { get; set; }
        /// <summary>
        /// 文件大小
        /// </summary>
        [XmlElement("fileBytes")]
        public long fileBytes { get; set; }
        /// <summary>
        /// 文件最后修改时间
        /// </summary>
        [XmlElement("lastWTime")]
        public string lastWTime { get; set; }

        [XmlIgnore]
        public string loadprogress { get; set; }

        [XmlIgnore]
        public string targetPath { get; set; }
    }

    public class FileInfoModel_View
    {
        public string hash1 { get; set; }
        public string fileName { get; set; }
        public string fileBytes { get; set; }
        public string loadprogress { get; set; }
    }
}
